package com.example.test.newtab;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.example.test.GridViewActivity;
import com.example.test.ListViewActivity;
import com.example.test.NotificationActivity;
import com.example.test.R;
import com.example.test.broadcast.TestActivity;
import com.example.test.service.TestServiceActivity;

public class CountingFragment extends Fragment {
	int mNum;
	private Button btn_main_notify;
	private Button btn_main_gridview;
	private Button btn_main_listview;
	private Button btn_main_broadcast;
	private Button btn_main_service;
	private Button btn_tab_new;

	/**
	 * Create a new instance of CountingFragment, providing "num" as an
	 * argument.
	 */
	static CountingFragment newInstance(int num) {
		CountingFragment f = new CountingFragment();

		// Supply num input as an argument.
		Bundle args = new Bundle();
		args.putInt("num", num);
		f.setArguments(args);

		return f;
	}

	/**
	 * When creating, retrieve this instance's number from its arguments.
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mNum = getArguments() != null ? getArguments().getInt("num") : 1;
	}

	/**
	 * The Fragment's UI is just a simple text view showing its instance number.
	 */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.activity_main, container, false);
		btn_main_notify = (Button) v.findViewById(R.id.btn_main_notify);
		btn_main_gridview = (Button) v.findViewById(R.id.btn_main_gridview);
		btn_main_listview = (Button) v.findViewById(R.id.btn_main_listview);
		btn_main_broadcast = (Button) v.findViewById(R.id.btn_main_broadcast);
		btn_main_service = (Button) v.findViewById(R.id.btn_main_service);
		btn_tab_new = (Button) v.findViewById(R.id.btn_tab_new);

		btn_main_notify.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(getActivity(), NotificationActivity.class);
				startActivity(intent);
			}
		});
		btn_main_gridview.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(getActivity(), GridViewActivity.class);
				startActivity(intent);
			}
		});
		btn_main_listview.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(getActivity(), ListViewActivity.class);
				startActivity(intent);
			}
		});
		btn_main_broadcast.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(getActivity(), TestActivity.class);
				startActivity(intent);
			}
		});
		btn_main_service.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(getActivity(), TestServiceActivity.class);
				startActivity(intent);
			}
		});
		btn_tab_new.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent();
				intent.setClass(getActivity(), FragmentTabs.class);
				startActivity(intent);
			}
		});
		return v;
	}
}